# Copyright (c) 2013 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

import logging
import StringIO
import traceback
from zipfile import ZipFile

import file_reader

def read(config_helper, zip_file_name, path):
  zip_path = config_helper.get_zip_path(zip_file_name)
  zip_content = file_reader.read(config_helper, zip_path)
  if zip_content:
    try:
      with ZipFile(StringIO.StringIO(zip_content), 'r') as zip_obj:
        return zip_obj.read(path)
    except:
      logging.error(traceback.format_exc())
  return None
